﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;

namespace 写一个Ticket类实现距离与价格之间的关联
{
    internal class Program
    {
        class Ticket
        {
            public uint distance;
            public float price;

            public Ticket(uint distance)   //成员方法的使用
            {
                this.distance = distance;
                price = GetPrice();
            }
            private float GetPrice()
            {
                if (distance > 300)   //大于300公里9折
                {
                    return distance * 0.7f;
                }
                else if (distance > 201 && distance < 300)
                {
                    return distance * 0.8f;
                }
                else if (distance > 101 && distance < 200)
                {
                    return distance * 0.9f;
                }
                else
                {
                    return distance;
                }
            }
            public void ShowInfo()
            {
                Console.WriteLine("{0}公里{1}价格", distance, price);
            }

        }
        static void Main(string[] args)
        {
            Ticket f = new Ticket(400);
            f.ShowInfo();
        }
    }
}
